class Abstract {
  constraint = [];
  constructor(arg) {
    this.constraint = arg;
    if (new.target === Abstract) {
      throw new Error(`抽象类不允许实例化`);
    }
    Object.getOwnPropertyNames(new.target.prototype).map((prop) => {
      if (!["constructor"].concat(this.constraint).includes(prop)) {
        throw new Error(`${new.target.name}类实列方法${prop}未定义`);
      }
    });
    this.constraint.map((func) => {
      if (!Object.getOwnPropertyNames(new.target.prototype).includes(func)) {
        throw new Error(`${new.target.name}类实列方法${func}未实现`);
      }
    });
  }
}



export class StoreImp extends Abstract {
  constructor() {
    super([
      "initParams",
      "initComponentTree",
      "findContainers",
      "switchComponent",
      "generateComponent",
      "addComponentMap",
      "deepCloneComponentMap",
      "delComponentMap",
      "isRepeat",
      "checkRepeat",
      "openDialog",
      "saveDialog",
      "selector",
    ]);
    if (new.target === StoreImp) {
      throw new Error(`抽象类不允许实例化`);
    }
  }
}

export class EventImp extends Abstract {
  constructor() {
    super(["__init", "on", "fire", "off"]);
    if (new.target === EventImp) {
      throw new Error(`抽象类不允许实例化`);
    }
  }
}

export class VDomImp extends Abstract {
  constructor() {
    super(["selector", "set", "get"]);
    if (new.target === VDomImp) {
      throw new Error(`抽象类不允许实例化`);
    }
  }
}


export class FormModelImp extends Abstract {
  constructor() {
    super(["buildModelsList"]);
    if (new.target === FormModelImp) {
      throw new Error(`抽象类不允许实例化`);
    }
  }
}


export class LifeCycleImp extends Abstract {
  constructor() {
    super(["created","beforeSubmit", "destroyed"]);
    if (new.target === LifeCycleImp) {
      throw new Error(`抽象类不允许实例化`);
    }
  }
}

